package com.steven.love.dao;

import com.steven.love.pojo.Diary;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface DiaryDao {

    @Select("SELECT * FROM love_diary WHERE isDeleted=1 ORDER BY createTime DESC")
    public List<Diary> queryAllLoveInfo();

    @Select("SELECT * FROM love_diary WHERE isDeleted=1 ORDER BY createTime DESC LIMIT 0,#{pageEnd}")
    public List<Diary> queryLoveInfo(Long pageStart,Long pageEnd);

    @Insert("INSERT INTO love_diary(author,content,createTime) value(#{author},#{content},#{time})")
    public int addLoveDiary(String author, String content, Long time);

    @Update("UPDATE love_diary set isDeleted=0 WHERE id=#{id}")
    public int deleteLoveDiary(Long id);

    @Select("SELECT * FROM unhappy_diary WHERE isDeleted=1 ORDER BY createTime DESC")
    public List<Diary> queryAllUnHappyInfo();

    @Select("SELECT * FROM unhappy_diary WHERE isDeleted=1 ORDER BY createTime DESC LIMIT 0,#{pageEnd}")
    public List<Diary> queryUnHappyInfo(Long pageStart,Long pageEnd);

    @Insert("INSERT INTO unhappy_diary(author,content,createTime) value(#{author},#{content},#{time})")
    public int addUnHappyDiary(String author, String content, Long time);

    @Update("UPDATE unhappy_diary set isDeleted=0 WHERE id=#{id}")
    public int deleteUnhappyDiary(Long id);
}
